//
//  ZBMoBanSixSecondCell.m
//  MoBan
//
//  Created by apple on 16/7/13.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "ZBMoBanSixSecondCell.h"
#import "ZBMoBanSixSmallView.h"
@interface ZBMoBanSixSecondCell()<ZBMoBanSixSmallViewDeleget>
@property(nonatomic,strong)UILabel *namelable;
@property(nonatomic,strong)UILabel *detailLable;
@property(nonatomic,strong)NSMutableArray *array;

@property(nonatomic,strong)ZBMoBanSixSmallView *smalview;


@end
@implementation ZBMoBanSixSecondCell
-(NSMutableArray *)array
{
    if (!_array) {
        _array = [NSMutableArray array];
    }
    return _array;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self =[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self addUI];
    }
    return self;

}
-(void)addUI
{
    self.namelable = [[UILabel alloc]init];
    self.namelable.text = @"嘉和一品粥";
    [self.contentView addSubview:self.namelable];
    
    self.detailLable = [[UILabel alloc]init];
    self.detailLable.font = [UIFont systemFontOfSize:13*Kscr];
    self.detailLable.text = @"嘉和一品粥嘉和一品粥嘉和一品粥嘉和一品粥嘉和一品粥嘉和一品粥嘉和一品粥嘉和一品粥";
    self.detailLable.numberOfLines = 0;
    [self.contentView addSubview:self.detailLable];

}
-(void)layoutSubviews
{
    [super layoutSubviews];
}
-(void)ZBSetMessageWithSouce:(NSMutableArray *)array
{
    [self ZBSetFram:array];
    
}
/**
 设置空间的位置
 */
-(void)ZBSetFram:(NSMutableArray *)array
{
    self.namelable.frame = CGRectMake(10*Kscr, 5*Kscr, 200*Kscr, 20*Kscr);
    self.detailLable.frame = CGRectMake(10*Kscr, self.namelable.bottom+5*Kscr, 350*Kscr, 40*Kscr);

    [self.array makeObjectsPerformSelector:@selector(removeFromSuperview)];
    [self.array removeAllObjects];
    
    for (NSInteger i=0; i<array.count; i++) {
        ZBMoBanSixSmallView *smallview = [[ZBMoBanSixSmallView alloc]init];
        self.smalview = smallview;
        smallview.deleget = self;
        [self.contentView addSubview:smallview];
        [self.array addObject:smallview];
        [smallview ZBGaveSmallViewMessage:array[i] Withtag:i];
        
        
    }

}

-(void)ZBGetSmallViewWidth:(CGFloat)width Withtag:(NSInteger)inter
{
    
    ZBMoBanSixSmallView *smallview = self.array[inter];
    if (inter==0) {
        smallview.frame = CGRectMake(10*Kscr, self.detailLable.bottom+5*Kscr, width, 20*Kscr);
    }else
    {
        ZBMoBanSixSmallView *oldsmalview = self.array[inter-1];
        
        smallview.frame = CGRectMake(oldsmalview.right, self.detailLable.bottom+5*Kscr, width, 20*Kscr);
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
